package GUI.main.dialogs;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.JScrollPane;

public class UserProfile extends JDialog implements ActionListener{

    /**
     * 
     */
    private static final long serialVersionUID = 1L;
    
    private JPanel topPanel;
    private JPanel mainPanel;
    private JPanel fPanel;
    private JPanel lPanel;
    private JPanel uPanel;
    private JPanel ePanel;
    private JPanel pPanel;
    private JPanel aPanel;
    
    private JPanel firstPanel;
    private JPanel lastPanel;
    private JPanel userPanel;
    private JPanel emailPanel;
    private JPanel phonePanel;
    private JPanel agePanel;
    
    private JLabel firstLabel;
    private JLabel lastLabel;
    private JLabel userLabel;
    private JLabel emailLabel;
    private JLabel phoneLabel;
    private JLabel ageLabel;
    
    private JButton fEdit;
    private JButton lEdit;
    private JButton uEdit;
    private JButton eEdit;
    private JButton pEdit;
    private JButton aEdit;
   
    private JPanel appointmentPanel;
    private JScrollPane appointmentScrollPane;
    private JList appointmentList;
    
    public final static int WIDTH = 450;
    public final static int HEIGHT = 500;
    
    public UserProfile(){
	setSize(new Dimension(WIDTH,HEIGHT));
	setLayout(new BorderLayout());
	add(getTopPanel(),BorderLayout.NORTH);
	add(getMainPanel(),BorderLayout.CENTER);
	//add(getAppointmentPanel(),BorderLayout.SOUTH);
    }
    
    private JPanel getTopPanel(){
	if(topPanel == null){
	    topPanel = new JPanel(){
		public void paintComponent(Graphics g){
		    super.paintComponent(g);
		    g.setColor(new Color(100, 150, 220));
		    g.fillRect(0, 0, getWidth(), getHeight());
		    g.setColor(Color.white);
		    g.setFont(new Font(Font.SANS_SERIF, Font.BOLD, 24));
		    g.drawString("USER:matthew", 24, getHeight() - 8);
		}
	    };
	    topPanel.setPreferredSize(new Dimension(WIDTH, 75));
	}
	return topPanel;
    }
    
    private JPanel getMainPanel(){
	if(mainPanel == null){
	    mainPanel = new JPanel();
	    mainPanel.setLayout(new GridBagLayout());
	    
	    GridBagConstraints gbc1 = new GridBagConstraints();
	    gbc1.gridx = 0;
	    gbc1.gridy = 0;
	    mainPanel.add(getFPanel(),gbc1);
	    
	    GridBagConstraints gbc2 = new GridBagConstraints();
	    gbc2.gridx = 1;
	    gbc2.gridy = 0;
	    gbc2.weightx = 1;
	    gbc2.anchor = GridBagConstraints.WEST;
	    mainPanel.add(getFirstPanel(),gbc2);
	    
	    
	    GridBagConstraints gbc3 = new GridBagConstraints();
	    gbc3.gridx = 0;
	    gbc3.gridy = 1;
	    mainPanel.add(getLPanel(),gbc3);
	    
	    GridBagConstraints gbc4 = new GridBagConstraints();
	    gbc4.gridx = 1;
	    gbc4.gridy = 1;
	    gbc4.weightx = 1;
	    gbc4.anchor = GridBagConstraints.WEST;
	    mainPanel.add(getLastPanel(),gbc4);
	    
	    GridBagConstraints gbc5 = new GridBagConstraints();
	    gbc5.gridx = 0;
	    gbc5.gridy = 2;
	    mainPanel.add(getUPanel(),gbc5);
	    
	    GridBagConstraints gbc6 = new GridBagConstraints();
	    gbc6.gridx = 1;
	    gbc6.gridy = 2;
	    gbc6.weightx = 1;
	    gbc6.anchor = GridBagConstraints.WEST;
	    mainPanel.add(getUserPanel(),gbc6);
	    
	    GridBagConstraints gbc7 = new GridBagConstraints();
	    gbc7.gridx = 0;
	    gbc7.gridy = 3;
	    mainPanel.add(getEPanel(),gbc7);
	    
	    GridBagConstraints gbc8 = new GridBagConstraints();
	    gbc8.gridx = 1;
	    gbc8.gridy = 3;
	    gbc2.weightx = 1;
	    gbc2.anchor = GridBagConstraints.WEST;
	    mainPanel.add(getEmailPanel(),gbc8);
	    
	    GridBagConstraints gbc9 = new GridBagConstraints();
	    gbc9.gridx = 0;
	    gbc9.gridy = 4;
	    mainPanel.add(getPPanel(),gbc9);
	    
	    GridBagConstraints gbc10 = new GridBagConstraints();
	    gbc10.gridx = 1;
	    gbc10.gridy = 4;
	    gbc2.weightx = 1;
	    gbc2.anchor = GridBagConstraints.WEST;
	    mainPanel.add(getPhonePanel(),gbc10);
	    
	    GridBagConstraints gbc11 = new GridBagConstraints();
	    gbc11.gridx = 0;
	    gbc11.gridy = 5;
	    mainPanel.add(getAPanel(),gbc11);
	    
	    GridBagConstraints gbc12 = new GridBagConstraints();
	    gbc12.gridx = 1;
	    gbc12.gridy = 5;
	    gbc2.weightx = 1;
	    gbc2.anchor = GridBagConstraints.WEST;
	    mainPanel.add(getAgePanel(),gbc12);
	}
	return mainPanel;
    }
    
    private JPanel getFPanel(){
	if(fPanel == null){
	    fPanel = new JPanel(){
		public void paintComponent(Graphics g){
		    super.paintComponent(g);
			g.setColor(new Color(100, 150, 220));
			g.fillRect(0, 0, getWidth(), getHeight());
			g.setColor(Color.white);
			g.setFont(new Font(Font.SANS_SERIF, Font.BOLD, 12));
			g.drawString("f:", 10, getHeight() - 8);
		}
	    };
	    fPanel.setPreferredSize(new Dimension(25,25));
	}
	return fPanel;
    }
    
    private JPanel getLPanel(){
	if(lPanel == null){
	    lPanel = new JPanel(){
		public void paintComponent(Graphics g){
		    super.paintComponent(g);
			g.setColor(new Color(100, 150, 220));
			g.fillRect(0, 0, getWidth(), getHeight());
			g.setColor(Color.white);
			g.setFont(new Font(Font.SANS_SERIF, Font.BOLD, 12));
			g.drawString("l:", 10, getHeight() - 8);
		}
	    };
	    lPanel.setPreferredSize(new Dimension(25,25));
	}
	return lPanel;
    }
    
    private JPanel getUPanel(){
	if(uPanel == null){
	    uPanel = new JPanel(){
		public void paintComponent(Graphics g){
		    super.paintComponent(g);
			g.setColor(new Color(100, 150, 220));
			g.fillRect(0, 0, getWidth(), getHeight());
			g.setColor(Color.white);
			g.setFont(new Font(Font.SANS_SERIF, Font.BOLD, 12));
			g.drawString("u:", 10, getHeight() - 8);
		}
	    };
	    uPanel.setPreferredSize(new Dimension(25,25));
	}
	return uPanel;
    }
    
    private JPanel getEPanel(){
	if(ePanel == null){
	    ePanel = new JPanel(){
		public void paintComponent(Graphics g){
		    super.paintComponent(g);
			g.setColor(new Color(100, 150, 220));
			g.fillRect(0, 0, getWidth(), getHeight());
			g.setColor(Color.white);
			g.setFont(new Font(Font.SANS_SERIF, Font.BOLD, 12));
			g.drawString("e:", 10, getHeight() - 8);
		}
	    };
	    ePanel.setPreferredSize(new Dimension(25,25));
	}
	return ePanel;
    }
    
    private JPanel getPPanel(){
	if(pPanel == null){
	    pPanel = new JPanel(){
		public void paintComponent(Graphics g){
		    super.paintComponent(g);
			g.setColor(new Color(100, 150, 220));
			g.fillRect(0, 0, getWidth(), getHeight());
			g.setColor(Color.white);
			g.setFont(new Font(Font.SANS_SERIF, Font.BOLD, 12));
			g.drawString("p:", 10, getHeight() - 8);
		}
	    };
	    pPanel.setPreferredSize(new Dimension(25,25));
	}
	return pPanel;
    }
    private JPanel getAPanel(){
	if(aPanel == null){
	    aPanel = new JPanel(){
		public void paintComponent(Graphics g){
		    super.paintComponent(g);
			g.setColor(new Color(100, 150, 220));
			g.fillRect(0, 0, getWidth(), getHeight());
			g.setColor(Color.white);
			g.setFont(new Font(Font.SANS_SERIF, Font.BOLD, 12));
			g.drawString("a:", 10, getHeight() - 8);
		}
	    };
	    aPanel.setPreferredSize(new Dimension(25,25));
	}
	return aPanel;
    }
    
    private JPanel getFirstPanel(){
	if(firstPanel == null){
	    firstPanel = new JPanel();
	    firstPanel.setLayout(new BorderLayout());
	    firstPanel.setPreferredSize(new Dimension(200,25));
	    firstPanel.add(getFirstLabel(),BorderLayout.WEST);
	    firstPanel.add(getFEdit(),BorderLayout.EAST);
	    firstPanel.add(new JPanel(),BorderLayout.CENTER);
	}
	return firstPanel;
    }

    private JPanel getLastPanel(){
	if(lastPanel == null){
	    lastPanel = new JPanel();
	    lastPanel.setLayout(new BorderLayout());
	    lastPanel.setPreferredSize(new Dimension(200,25));
	    lastPanel.add(getLastLabel(),BorderLayout.WEST);
	    lastPanel.add(getLEdit(),BorderLayout.EAST);
	    lastPanel.add(new JPanel(),BorderLayout.CENTER);
	}
	return lastPanel;
    }

    private JPanel getUserPanel(){
	if(userPanel == null){
	    userPanel = new JPanel();
	    userPanel.setLayout(new BorderLayout());
	    userPanel.setPreferredSize(new Dimension(200,25));
	    userPanel.add(getUserLabel(),BorderLayout.WEST);
	    userPanel.add(getUEdit(),BorderLayout.EAST);
	    userPanel.add(new JPanel(),BorderLayout.CENTER);
	}
	return userPanel;
    }

    private JPanel getEmailPanel(){
	if(emailPanel == null){
	    emailPanel = new JPanel();
	    emailPanel.setLayout(new BorderLayout());
	    emailPanel.setPreferredSize(new Dimension(200,25));
	    emailPanel.add(getEmailLabel(),BorderLayout.WEST);
	    emailPanel.add(getEEdit(),BorderLayout.EAST);
	    emailPanel.add(new JPanel(),BorderLayout.CENTER);
	}
	return emailPanel;
    }

    private JPanel getPhonePanel(){
	if(phonePanel == null){
	    phonePanel = new JPanel();
	    phonePanel.setLayout(new BorderLayout());
	    phonePanel.setPreferredSize(new Dimension(200,25));
	    phonePanel.add(getPhoneLabel(),BorderLayout.WEST);
	    phonePanel.add(getPEdit(),BorderLayout.EAST);
	    phonePanel.add(new JPanel(),BorderLayout.CENTER);
	}
	return phonePanel;
    }

    private JPanel getAgePanel(){
	if(agePanel == null){
	    agePanel = new JPanel();
	    agePanel.setLayout(new BorderLayout());
	    agePanel.setPreferredSize(new Dimension(200,25));
	    agePanel.add(getAgeLabel(),BorderLayout.WEST);
	    agePanel.add(getAEdit(),BorderLayout.EAST);
	    agePanel.add(new JPanel(),BorderLayout.CENTER);
	}
	return agePanel;
    }
    
    private JLabel getFirstLabel(){
	if(firstLabel == null){
	    firstLabel = new JLabel("Matthew");
	}
	return firstLabel;
    }
    
    private JLabel getLastLabel(){
	if(lastLabel == null){
	    lastLabel = new JLabel("Ramsey");
	}
	return lastLabel;
    }
    
    private JLabel getUserLabel(){
	if(userLabel == null){
	    userLabel = new JLabel("mramsey3");
	}
	return userLabel;
    }
    
    private JLabel getEmailLabel(){
	if(emailLabel == null){
	    emailLabel = new JLabel("mramsey3@gatech.edu");
	}
	return emailLabel;
    }
    
    private JLabel getPhoneLabel(){
	if(phoneLabel == null){
	    phoneLabel = new JLabel("828-342-0437");
	}
	return phoneLabel;
    }
    
    private JLabel getAgeLabel(){
	if(ageLabel == null){
	    ageLabel = new JLabel("22");
	}
	return ageLabel;
    }
    
    private JButton getFEdit(){
	if(fEdit == null){
	    fEdit = new JButton("edit");
	    fEdit.addActionListener(this);
	}
	return fEdit;
    }
    
    private JButton getLEdit(){
	if(lEdit == null){
	    lEdit = new JButton("edit");
	    lEdit.addActionListener(this);
	}
	return lEdit;
    }
    
    private JButton getUEdit(){
	if(uEdit == null){
	    uEdit = new JButton("edit");
	    uEdit.addActionListener(this);
	}
	return uEdit;
    }

    private JButton getEEdit(){
	if(eEdit == null){
	    eEdit = new JButton("edit");
	    eEdit.addActionListener(this);
	}
	return eEdit;
    }
    
    private JButton getPEdit(){
	if(pEdit == null){
	    pEdit = new JButton("edit");
	    pEdit.addActionListener(this);
	}
	return pEdit;
    }
    
    private JButton getAEdit(){
	if(aEdit == null){
	    aEdit = new JButton("edit");
	    aEdit.addActionListener(this);
	}
	return aEdit;
    }
    
    @Override
    public void actionPerformed(ActionEvent arg0) {
	// TODO Auto-generated method stub
	
    }
}
